package com.hx.er.action.admin.msg;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.hx.er.action.base.ErAdminPageAction;
import com.hx.er.bean.base.StatusBean;
import com.hx.er.bean.detail.MessageDetailBean;
import com.hx.er.common.system.Constants;
import com.hx.er.common.util.StringUtil;
import com.hx.er.service.admin.IAdminMsgService;

public class AdminMsgListAction extends ErAdminPageAction {
	// 序列化ID
	private static final long serialVersionUID = 1112864183078525565L;

	private List<StatusBean> flowStatusList;
	private List<MessageDetailBean> msgList;
	private String submitUserName;
	private String restName;
	private long flowStatusId = 9;

	@Autowired
	private IAdminMsgService adminMsgService;

	public String init() {
		// 初始化页面检索条件
		this.initPage();

		// 检索条件
		Map<String, Object> conditions = super.getConditionMap();
		conditions.put("submitUserName", StringUtil.EmptyToNull(StringUtil.trim(this.submitUserName)));
		conditions.put("restName", StringUtil.EmptyToNull(StringUtil.trim(this.restName)));
		conditions.put("flowStatusId", this.flowStatusId);

		// 查询列表
		this.msgList = this.adminMsgService.getMsgDetailAliveList(conditions);
		int msgCount = this.adminMsgService.getMsgDetailAliveCount(conditions);
		super.pageCount = (int) Math.ceil(msgCount / (double) super.dataListLimit);

		return SUCCESS;
	}

	private void initPage() {
		// 初始化检索条件下拉框
		this.flowStatusList = new ArrayList<>();
		StatusBean status0 = new StatusBean();
		status0.setId(0);
		status0.setName(super.getText(Constants.PROPERTY_FLOW_STATUS_VALUE0));
		StatusBean status1 = new StatusBean();
		status1.setId(1);
		status1.setName(super.getText(Constants.PROPERTY_FLOW_STATUS_VALUE1));
		StatusBean status8 = new StatusBean();
		status8.setId(8);
		status8.setName(super.getText(Constants.PROPERTY_FLOW_STATUS_VALUE8));
		StatusBean status9 = new StatusBean();
		status9.setId(9);
		status9.setName(super.getText(Constants.PROPERTY_FLOW_STATUS_VALUE9));
		this.flowStatusList.add(status9);
		this.flowStatusList.add(status1);
		this.flowStatusList.add(status0);
		this.flowStatusList.add(status8);
	}

	public List<StatusBean> getFlowStatusList() {
		return flowStatusList;
	}

	public void setFlowStatusList(List<StatusBean> flowStatusList) {
		this.flowStatusList = flowStatusList;
	}

	public List<MessageDetailBean> getMsgList() {
		return msgList;
	}

	public void setMsgList(List<MessageDetailBean> msgList) {
		this.msgList = msgList;
	}

	public String getSubmitUserName() {
		return submitUserName;
	}

	public void setSubmitUserName(String submitUserName) {
		this.submitUserName = submitUserName;
	}

	public String getRestName() {
		return restName;
	}

	public void setRestName(String restName) {
		this.restName = restName;
	}

	public long getFlowStatusId() {
		return flowStatusId;
	}

	public void setFlowStatusId(long flowStatusId) {
		this.flowStatusId = flowStatusId;
	}

}
